package org.fast.easy.system.feign.service;

import org.fast.easy.core.domain.result.R;
import org.fast.easy.system.core.domain.vo.SysDictDataVo;
import org.fast.easy.system.feign.factory.SystemFeignFallbackFactory;

import org.fast.easy.system.upms.domain.bo.SysDeptBo;
import org.fast.easy.system.upms.domain.vo.SysDeptVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

import static org.fast.easy.system.feign.constant.SystemServiceNameConstants.*;


/**
 * 类说明
 *
 * @author YanMing
 * @date 2024/5/15
 */
@FeignClient(contextId = SYSTEM_FEIGN_SERVICE_CONTEXT_ID, value = SYSTEM_FEIGN_SERVICE_NAME, fallbackFactory = SystemFeignFallbackFactory.class)
public interface SystemFeignService {
    /**
     * 部门列表
     * Feign发送Get请求时，采用POJO传递参数 Method Not Allowed 405
     * （在 HttpURLConnection 中发现的，jdk原生的http连接请求工具类，原来是因为Feign默认使用的连接工具实现类，所以里面发现只要你有body体对象，就会强制的把get请求转换成POST请求。）
     * 解决办法：https://blog.csdn.net/echizao1839/article/details/128703362
     * fast-easy-framework-cloud
     * @param dept
     * @return
     */
    @GetMapping(SYSTEM_DEPT_SERVICE_MAPPING+"/list")
    R<List<SysDeptVo>> deptList(SysDeptBo dept) ;

    @GetMapping(SYSTEM_DEPT_SERVICE_MAPPING+"/list")
    R<List<SysDeptVo>> deptList(@RequestParam Map<String,Object> param) ;

    @GetMapping(SYSTEM_DEPT_SERVICE_MAPPING+"/list")
    R<List<SysDeptVo>> deptList(@RequestParam("parentId") Long parentId) ;

    /**
     * 根据字典类型查询字典数据信息
     *
     * @param dictType 字典类型
     */
    @GetMapping(value = SYSTEM_DICT_DATA_SERVICE_MAPPING+"/type/{dictType}")
    R<List<SysDictDataVo>> dictDataByType(@PathVariable("dictType") String dictType);

}
